<?php
/* @var $this AdController */
/* @var $model AdForm */
/* @var $form CActiveForm */
?>
<?php $form=$this->beginWidget('CActiveForm', array(
    'id'=>'ad-form',
    // Please note: When you enable ajax validation, make sure the corresponding
    // controller action is handling ajax validation correctly.
    // There is a call to performAjaxValidation() commented in generated controller code.
    // See class documentation of CActiveForm for details on this.
    'htmlOptions'=>array('class'=>'form-horizontal', 'enctype'=>'multipart/form-data'),
    'enableAjaxValidation'=>false,
)); ?>

    <?php echo $form->errorSummary($model); ?>
    <input type="hidden" name="AdForm[type]" value="3">
    <?php $value = json_decode($model->value);?>
    <div class="form-group">
        <?php echo $form->labelEx($model,'name', array('class'=>'col-sm-2 control-label')); ?>
        <div class="col-sm-10">
            <?php echo $form->textField($model,'name',array('size'=>60,'maxlength'=>255,'class'=>'form-control')); ?>
        </div>
    </div>

    <div class="form-group">
        <?php echo $form->labelEx($model,'tips', array('class'=>'col-sm-2 control-label')); ?>
        <div class="col-sm-10">
            <?php echo $form ->textField( $model , 'tips', array('size'=>60,'maxlength'=>255,'class'=>'form-control'));?>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label required">广告类型 <span class="required">*</span></label>
        <div class="col-sm-10">
            <?php echo $form ->dropDownList( $model , 'input_type', array(''=>'请选择','1'=>'image','2'=>'video','3'=>'text'),array('class'=>'form-control','id'=>'adForm-input_type'));?>
        </div>
    </div>
    <div class="form-group input_1 field-adForm-ad">
        <label class="col-sm-2 control-label">广告内容</label>
        <div class="col-sm-10">
            <input type="hidden" name="AdForm[ad]" value="">
            <input type="file" id="AdForm-ad" class="pretty-file img-responsive" name="AdForm[ad]" value="<?php if($value){echo $value->ad;}?>" text="选择图片">
            <div style='position: relative'>
                <img class="pretty-file img-responsive" src="<?php if($value){echo $value->ad;}?>" alt="" text="选择图片" nonePicUrl="/resource/backend/images/none.jpg">
                <?php if($value && $value->ad){?>
                <div onclick="$(this).parents('.image').find('input[type=hidden]').val(0);$(this).prev().attr('src', '/resource/backend/images/none.jpg');$(this).remove()" style='position:absolute;width:50px;padding:5px 3px 3px 5px;top:5px;left:6px;background:black;opacity:0.6;color:white;cursor:pointer'><i class='fa fa-trash' aria-hidden='true'> 删除</i></div>
                <?php }?>
            </div>

        </div>
    </div>
    <div class="form-group input_2 field-adForm-ad">
        <label class="col-sm-2 control-label">广告内容</label>
        <div class="col-sm-10">
            <input type="hidden" name="AdForm[ad]" value="">
            <input type="file" name="AdForm[ad]" value="<?php if($value){echo $value->ad;}?>" class="form-control" text="选择文件">
        </div>
    </div>
    <div class="form-group input_3 field-adForm-ad">
        <label class="col-sm-2 control-label">广告内容</label>
        <div class="col-sm-10">
            <textarea id="" class="form-control" name="AdForm[ad]" rows="5"><?php if($value){echo $value->ad;}?></textarea>
        </div>
    </div>

    <div class="form-group">
        <label class="col-sm-2 control-label">跳转链接</label>
        <div class="col-sm-10">
            <input type="input" name="AdForm[link]" value="<?php if($value){echo $value->link;}?>" class="form-control">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">广告描述</label>
        <div class="col-sm-10">
            <input type="text" id="AdForm-desc" name="AdForm[desc]" value="<?php if($value){echo $value->desc;}?>" class="form-control">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">新窗口打开</label>
        <div class="col-sm-10">
            <input type="radio" id="AdForm[target]1" name="AdForm[target]" value="_blank" <?php if($value){if($value->target=='_blank'){echo'checked';}}else{echo'checked';}?>><label for="AdForm[target]1"> 是 </label>&nbsp;&nbsp;
            <input type="radio" id="AdForm[target]2" name="AdForm[target]" value="_self" <?php if($value){if($value->target=='_self'){echo'checked';}}?>><label for="AdForm[target]2"> 否 </label>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">排序</label>
        <div class="col-sm-10">
            <?php echo $form ->textField( $model , 'sort', array('size'=>60,'maxlength'=>255,'class'=>'form-control'));?>
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-2 control-label">状态</label>
        <div class="col-sm-10">
            <?php echo $form ->radioButtonList( $model , 'autoload', array('1'=>'启用','0'=>'禁用'),array('separator'=>'&nbsp;&nbsp;', 'class'=>''));?>
        </div>
    </div>
    <div class="hr hr-18 dotted"></div>
    <div class="clearfix">
        <div class="col-md-offset-2 col-md-10">
            <button class="btn btn-white btn-info btn-round" type="submit"><i class="ace-icon fa fa-floppy-o bigger-120 blue"></i>保存</button>
            &nbsp;
            <button class="btn btn-white btn-default btn-round" type="reset"><i class="ace-icon fa fa-times red2"></i>取消</button>
        </div>
    </div>
<?php $this->endWidget(); ?>